
import 'package:Flutter_Demo/core/model/meal_model.dart';
import 'package:Flutter_Demo/core/services/http_request.dart';
import 'package:Flutter_Demo/core/services/json_parse.dart';

class MYMealRequest {

   static Future<List<MYMealModel>> getMealData() async {
    // 发送网络请求
    final url = "/json/meal.json";
    final reslut = await HttpRequest.request(url);
    // json转model
    final mealArray = reslut["meal"];
    List<MYMealModel> meals = [];
    for(var json in mealArray) {
      meals.add(MYMealModel.fromJson(json));
    }

//    if(meals.length == 0) {
//      MYJsonParse.getMealData().then((value) {
//        meals = value;
//      });
//    }


    return meals;
  }

}